import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);

const routes = [
  {
    path: '*',
    redirect: { name: 'discover' }
  },
  {
    path: '/discover',
    name: 'discover',
    meta: { title: '发现音乐' },
    component: () => import('@/views/Page-discover.vue'),
    redirect: { name: 'recommend' },
    children: [
      {
        name: 'recommend',
        path: '/recommend',
        meta: { title: '个性推荐' },
        component: () => import('@/components/Page-discover/Page-recommend.vue')
      },
      {
        name: 'playlist',
        path: '/playlist',
        meta: { title: '歌单' },
        component: () => import('@/components/Page-discover/Page-playlist.vue')
      },
      {
        name: 'ranking',
        path: '/ranking',
        meta: { title: '排行榜' },
        component: () => import('@/components/Page-discover/Page-ranking.vue')
      },
      {
        name: 'singer',
        path: '/singer',
        meta: { title: '歌手' },
        component: () => import('@/components/Page-discover/Page-singer.vue')
      },
      {
        name: 'new-music',
        path: '/new-music',
        meta: { title: '最新音乐' },
        component: () => import('@/components/Page-discover/Page-new-music.vue')
      },
      {
        name: 'host-station',
        path: '/host-station',
        meta: { title: '主播电台', disabled: !true },
        component: () => import('@/components/Page-discover/Page-host-station.vue')
      }
    ]
  },
  {
    path: '/local-music',
    name: 'local-music',
    meta: { title: '本地音乐' },
    component: () => import('@/views/Page-local-music.vue')
  },
  {
    path: '/my-music-cloud',
    name: 'my-music-cloud',
    meta: { title: '我的音乐云盘' },
    component: () => import('@/views/Page-my-music-cloud.vue')
  },
  {
    path: '/my-favorite',
    name: 'my-favorite',
    meta: { title: '我的收藏' },
    component: () => import('@/views/Page-my-favorite.vue')
  },
  {
    path: '/song-list/:id',
    name: 'song-list',
    meta: { title: '歌单' },
    props: true,
    component: () => import('@/views/Page-song-list.vue')
  },
  {
    path: '/search/:keys',
    name: 'search',
    meta: { title: '搜索结果' },
    props: true,
    component: () => import('@/views/Page-search.vue')
  },
  {
    path: '/personal',
    name: 'personal',
    meta: { title: '个人中心' },
    component: () => import('@/views/Page-personal.vue')
  }
];

const router = new VueRouter({
  // mode: 'history',
  base: process.env.BASE_URL,
  routes
});

export default router;
